@dynamic-labs/legacy-react-native-extension 0.0.0 → 5.1.0

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.
Files changed (76) hide show
  1. package/README.md +7 -0
  2. package/android/AndroidManifest.xml +1 -0
  3. package/android/EmbeddedWebViewController.kt +559 -0
  4. package/android/EmbeddedWebViewModule.kt +62 -0
  5. package/android/KeyStoreKeyManager.kt +154 -0
  6. package/android/KeychainModule.kt +71 -0
  7. package/android/build.gradle +38 -0
  8. package/android/dynamic/embeddedwebview/EmbeddedWebViewController.kt +559 -0
  9. package/android/dynamic/embeddedwebview/EmbeddedWebViewModule.kt +62 -0
  10. package/android/dynamic/keychain/KeyStoreKeyManager.kt +154 -0
  11. package/android/dynamic/keychain/KeychainModule.kt +71 -0
  12. package/android/embeddedwebview/EmbeddedWebViewController.kt +559 -0
  13. package/android/embeddedwebview/EmbeddedWebViewModule.kt +62 -0
  14. package/android/java/xyz/dynamic/embeddedwebview/EmbeddedWebViewController.kt +559 -0
  15. package/android/java/xyz/dynamic/embeddedwebview/EmbeddedWebViewModule.kt +62 -0
  16. package/android/java/xyz/dynamic/keychain/KeyStoreKeyManager.kt +154 -0
  17. package/android/java/xyz/dynamic/keychain/KeychainModule.kt +71 -0
  18. package/android/keychain/KeyStoreKeyManager.kt +154 -0
  19. package/android/keychain/KeychainModule.kt +71 -0
  20. package/android/main/AndroidManifest.xml +1 -0
  21. package/android/main/java/xyz/dynamic/embeddedwebview/EmbeddedWebViewController.kt +559 -0
  22. package/android/main/java/xyz/dynamic/embeddedwebview/EmbeddedWebViewModule.kt +62 -0
  23. package/android/main/java/xyz/dynamic/keychain/KeyStoreKeyManager.kt +154 -0
  24. package/android/main/java/xyz/dynamic/keychain/KeychainModule.kt +71 -0
  25. package/android/src/main/AndroidManifest.xml +1 -0
  26. package/android/src/main/java/xyz/dynamic/embeddedwebview/EmbeddedWebViewController.kt +559 -0
  27. package/android/src/main/java/xyz/dynamic/embeddedwebview/EmbeddedWebViewModule.kt +62 -0
  28. package/android/src/main/java/xyz/dynamic/keychain/KeyStoreKeyManager.kt +154 -0
  29. package/android/src/main/java/xyz/dynamic/keychain/KeychainModule.kt +71 -0
  30. package/android/xyz/dynamic/embeddedwebview/EmbeddedWebViewController.kt +559 -0
  31. package/android/xyz/dynamic/embeddedwebview/EmbeddedWebViewModule.kt +62 -0
  32. package/android/xyz/dynamic/keychain/KeyStoreKeyManager.kt +154 -0
  33. package/android/xyz/dynamic/keychain/KeychainModule.kt +71 -0
  34. package/expo-module.config.json +12 -0
  35. package/index.cjs +998 -0
  36. package/index.js +973 -0
  37. package/ios/EmbeddedWebViewController.swift +500 -0
  38. package/ios/EmbeddedWebViewModule.swift +69 -0
  39. package/ios/Keychain.podspec +15 -0
  40. package/ios/KeychainModule.swift +39 -0
  41. package/ios/SecureEnclaveKeyManager.swift +187 -0
  42. package/package.json +44 -1
  43. package/src/ReactNativeExtension/ReactNativeExtension.d.ts +64 -0
  44. package/src/ReactNativeExtension/index.d.ts +1 -0
  45. package/src/ReactNativeExtension/logNativeModuleAvailability.d.ts +19 -0
  46. package/src/ReactNativeExtension/setupKeychainHandler/index.d.ts +1 -0
  47. package/src/ReactNativeExtension/setupKeychainHandler/setupKeychainHandler.d.ts +2 -0
  48. package/src/ReactNativeExtension/setupPasskeyHandler/index.d.ts +1 -0
  49. package/src/ReactNativeExtension/setupPasskeyHandler/setupPasskeyHandler.d.ts +2 -0
  50. package/src/ReactNativeExtension/setupPlatformHandler/index.d.ts +1 -0
  51. package/src/ReactNativeExtension/setupPlatformHandler/setupPlatformHandler.d.ts +2 -0
  52. package/src/ReactNativeExtension/setupStorageHandler/index.d.ts +1 -0
  53. package/src/ReactNativeExtension/setupStorageHandler/setupStorageHandler.d.ts +2 -0
  54. package/src/ReactNativeExtension/setupTurnkeyPasskeyHandler/index.d.ts +1 -0
  55. package/src/ReactNativeExtension/setupTurnkeyPasskeyHandler/setupTurnkeyPasskeyHandler.d.ts +2 -0
  56. package/src/components/WebView/EmbeddedWebView/EmbeddedWebView.d.ts +13 -0
  57. package/src/components/WebView/EmbeddedWebView/index.d.ts +1 -0
  58. package/src/components/WebView/WebView.d.ts +37 -0
  59. package/src/components/WebView/WebView.styles.d.ts +26 -0
  60. package/src/components/WebView/index.d.ts +1 -0
  61. package/src/components/WebView/useMessageTransportWebViewBridge/index.d.ts +1 -0
  62. package/src/components/WebView/useMessageTransportWebViewBridge/useMessageTransportWebViewBridge.d.ts +6 -0
  63. package/src/components/WebView/useWebViewVisibility/index.d.ts +1 -0
  64. package/src/components/WebView/useWebViewVisibility/useWebViewVisibility.d.ts +4 -0
  65. package/src/components/WebView/utils/shouldAllowNavigation/index.d.ts +1 -0
  66. package/src/components/WebView/utils/shouldAllowNavigation/shouldAllowNavigation.d.ts +5 -0
  67. package/src/errors/WebViewFailedToLoadError.d.ts +1 -0
  68. package/src/index.d.ts +2 -0
  69. package/src/nativeModules/EmbeddedWebView.d.ts +68 -0
  70. package/src/nativeModules/Keychain.d.ts +23 -0
  71. package/src/nativeModules/index.d.ts +1 -0
  72. package/src/utils/logger.d.ts +2 -0
  73. package/turboModules/NativeDynamicWebView.ts +47 -0
  74. package/turboModules/NativeKeychain.ts +22 -0
  75. package/turboModules/NativeReactNativeManifest.ts +24 -0
  76. package/turboModules/NativeScreenshotProtection.ts +29 -0
@@ -0,0 +1,187 @@
1
+ import Foundation
2
+ import Security
3
+ import CryptoKit
4
+
5
+ public enum SecureEnclaveKeyManagerError: Error, LocalizedError {
6
+ case generateFailed(String)
7
+ case exportFailed(String)
8
+ case keyNotFound(String)
9
+ case signFailed(String)
10
+ case invalidBase64Input
11
+
12
+ public var errorDescription: String? {
13
+ switch self {
14
+ case .generateFailed(let detail):
15
+ return "Failed to generate key pair: \(detail)"
16
+ case .exportFailed(let detail):
17
+ return "Failed to export public key: \(detail)"
18
+ case .keyNotFound(let tag):
19
+ return "Key not found for tag: \(tag)"
20
+ case .signFailed(let detail):
21
+ return "Failed to sign: \(detail)"
22
+ case .invalidBase64Input:
23
+ return "Invalid base64url-encoded input"
24
+ }
25
+ }
26
+ }
27
+
28
+ /// Platform-agnostic Secure Enclave key manager.
29
+ /// Provides P-256 key generation, signing, and management backed by the iOS Secure Enclave.
30
+ /// All public keys are returned in uncompressed SEC1 format (65 bytes: 04 || x || y).
31
+ /// All binary data uses base64url encoding (RFC 4648 §5, no padding).
32
+ public class SecureEnclaveKeyManager {
33
+
34
+ // No state needed — all operations use the system Keychain and Secure Enclave directly
35
+ public init() {}
36
+
37
+ public func isAvailable() -> Bool {
38
+ if #available(iOS 13.0, *) {
39
+ return SecureEnclave.isAvailable
40
+ }
41
+ return false
42
+ }
43
+
44
+ public func hasKey(tag: String) -> Bool {
45
+ let query = baseQuery(for: tag, returning: true)
46
+ var item: CFTypeRef?
47
+ let status = SecItemCopyMatching(query as CFDictionary, &item)
48
+ return status == errSecSuccess
49
+ }
50
+
51
+ public func generateKeyPair(tag: String) throws -> String {
52
+ let tagData = tag.data(using: .utf8)!
53
+
54
+ let access = SecAccessControlCreateWithFlags(
55
+ kCFAllocatorDefault,
56
+ kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly,
57
+ .privateKeyUsage,
58
+ nil
59
+ )!
60
+
61
+ let attributes: [String: Any] = [
62
+ kSecAttrKeyType as String: kSecAttrKeyTypeECSECPrimeRandom,
63
+ kSecAttrKeySizeInBits as String: 256,
64
+ kSecAttrTokenID as String: kSecAttrTokenIDSecureEnclave,
65
+ kSecPrivateKeyAttrs as String: [
66
+ kSecAttrIsPermanent as String: true,
67
+ kSecAttrApplicationTag as String: tagData,
68
+ kSecAttrAccessControl as String: access,
69
+ ] as [String: Any],
70
+ ]
71
+
72
+ var error: Unmanaged<CFError>?
73
+ guard let privateKey = SecKeyCreateRandomKey(attributes as CFDictionary, &error) else {
74
+ throw SecureEnclaveKeyManagerError.generateFailed(
75
+ "\(error!.takeRetainedValue())"
76
+ )
77
+ }
78
+
79
+ guard let publicKey = SecKeyCopyPublicKey(privateKey) else {
80
+ throw SecureEnclaveKeyManagerError.exportFailed("Failed to extract public key")
81
+ }
82
+ let publicKeyData = try exportPublicKey(publicKey)
83
+ return base64urlEncode(publicKeyData)
84
+ }
85
+
86
+ public func getPublicKey(tag: String) throws -> String? {
87
+ let query = baseQuery(for: tag, returning: true)
88
+
89
+ var item: CFTypeRef?
90
+ let status = SecItemCopyMatching(query as CFDictionary, &item)
91
+
92
+ guard status == errSecSuccess else {
93
+ return nil
94
+ }
95
+
96
+ guard let item else {
97
+ throw SecureEnclaveKeyManagerError.keyNotFound(tag)
98
+ }
99
+ let privateKey = item as! SecKey
100
+ guard let publicKey = SecKeyCopyPublicKey(privateKey) else {
101
+ throw SecureEnclaveKeyManagerError.exportFailed("Failed to extract public key")
102
+ }
103
+ let publicKeyData = try exportPublicKey(publicKey)
104
+ return base64urlEncode(publicKeyData)
105
+ }
106
+
107
+ public func sign(tag: String, payload: Data) throws -> String {
108
+ let query = baseQuery(for: tag, returning: true)
109
+
110
+ var item: CFTypeRef?
111
+ let status = SecItemCopyMatching(query as CFDictionary, &item)
112
+
113
+ guard status == errSecSuccess else {
114
+ throw SecureEnclaveKeyManagerError.keyNotFound(tag)
115
+ }
116
+
117
+ guard let item else {
118
+ throw SecureEnclaveKeyManagerError.keyNotFound(tag)
119
+ }
120
+ let privateKey = item as! SecKey
121
+
122
+ var error: Unmanaged<CFError>?
123
+ guard let signature = SecKeyCreateSignature(
124
+ privateKey,
125
+ .ecdsaSignatureMessageX962SHA256,
126
+ payload as CFData,
127
+ &error
128
+ ) else {
129
+ throw SecureEnclaveKeyManagerError.signFailed(
130
+ "\(error!.takeRetainedValue())"
131
+ )
132
+ }
133
+
134
+ return base64urlEncode(signature as Data)
135
+ }
136
+
137
+ public func deleteKey(tag: String) {
138
+ let query = baseQuery(for: tag, returning: false)
139
+ SecItemDelete(query as CFDictionary)
140
+ }
141
+
142
+ // MARK: - Private helpers
143
+
144
+ private func baseQuery(for tag: String, returning returnRef: Bool) -> [String: Any] {
145
+ var query: [String: Any] = [
146
+ kSecClass as String: kSecClassKey,
147
+ kSecAttrApplicationTag as String: tag.data(using: .utf8)!,
148
+ kSecAttrKeyType as String: kSecAttrKeyTypeECSECPrimeRandom,
149
+ ]
150
+ if returnRef {
151
+ query[kSecReturnRef as String] = true
152
+ }
153
+ return query
154
+ }
155
+
156
+ private func exportPublicKey(_ publicKey: SecKey) throws -> Data {
157
+ var error: Unmanaged<CFError>?
158
+ guard let data = SecKeyCopyExternalRepresentation(publicKey, &error) else {
159
+ throw SecureEnclaveKeyManagerError.exportFailed(
160
+ "\(error!.takeRetainedValue())"
161
+ )
162
+ }
163
+ // SecKeyCopyExternalRepresentation returns uncompressed SEC1 format (04 || x || y)
164
+ return data as Data
165
+ }
166
+
167
+ private func base64urlEncode(_ data: Data) -> String {
168
+ data.base64EncodedString()
169
+ .replacingOccurrences(of: "+", with: "-")
170
+ .replacingOccurrences(of: "/", with: "_")
171
+ .replacingOccurrences(of: "=", with: "")
172
+ }
173
+ }
174
+
175
+ public func base64urlDecode(_ string: String) throws -> Data {
176
+ var base64 = string
177
+ .replacingOccurrences(of: "-", with: "+")
178
+ .replacingOccurrences(of: "_", with: "/")
179
+ let remainder = base64.count % 4
180
+ if remainder > 0 {
181
+ base64 += String(repeating: "=", count: 4 - remainder)
182
+ }
183
+ guard let data = Data(base64Encoded: base64) else {
184
+ throw SecureEnclaveKeyManagerError.invalidBase64Input
185
+ }
186
+ return data
187
+ }
package/package.json CHANGED
@@ -1 +1,44 @@
1
- { "name": "@dynamic-labs/legacy-react-native-extension", "version": "0.0.0" }
1
+ {
2
+ "name": "@dynamic-labs/legacy-react-native-extension",
3
+ "version": "5.1.0",
4
+ "main": "./index.cjs",
5
+ "module": "./index.js",
6
+ "types": "./src/index.d.ts",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./src/index.d.ts",
11
+ "import": "./index.js",
12
+ "require": "./index.cjs"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "dependencies": {
17
+ "react-native-passkey": "3.3.2",
18
+ "@turnkey/react-native-passkey-stamper": "1.2.7",
19
+ "@react-native-documents/picker": "^11.0.0",
20
+ "react-native-fs": ">=2.20.0",
21
+ "@dynamic-labs/assert-package-version": "5.1.0",
22
+ "@dynamic-labs/legacy-client": "5.1.0",
23
+ "@dynamic-labs/logger": "5.1.0",
24
+ "@dynamic-labs/message-transport": "5.1.0",
25
+ "@dynamic-labs/webview-messages": "5.1.0"
26
+ },
27
+ "peerDependencies": {
28
+ "react": ">=18.0.0 <20.0.0",
29
+ "react-native": ">=0.73.6",
30
+ "react-native-keychain": ">=10.0.0",
31
+ "react-native-webview": "^13.6.4",
32
+ "expo-linking": ">=6.2.2",
33
+ "expo-web-browser": ">=12.0.0",
34
+ "expo-modules-core": ">=2.0.0"
35
+ },
36
+ "codegenConfig": {
37
+ "name": "DynamicClientSpec",
38
+ "type": "modules",
39
+ "jsSrcsDir": "turboModules",
40
+ "android": {
41
+ "javaPackageName": "xyz.dynamic.client"
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,64 @@
1
+ import { FC } from 'react';
2
+ import { Extension, WebViewLoadOptions } from '@dynamic-labs/legacy-client';
3
+ import { WebViewProps } from '../components/WebView';
4
+ export type ReactNativeExtensionProps = {
5
+ /**
6
+ * The URL to load in the WebView.
7
+ */
8
+ webviewUrl?: string;
9
+ /**
10
+ * Enable debugging in the WebView.
11
+ */
12
+ webviewDebuggingEnabled?: boolean;
13
+ /**
14
+ * The web origin of the app (e.g., 'https://demo.dynamic.xyz').
15
+ * Used for SIWE messages, fetch Origin headers, and passkey operations.
16
+ * Note: Deep link redirects use the auto-configured redirectUrl from expo-linking.
17
+ */
18
+ appOrigin?: string;
19
+ /**
20
+ * When true on iOS / Android, the SDK hosts the webview-controller in a
21
+ * native WKWebView (iOS) or android.webkit.WebView (Android) owned by a
22
+ * dedicated overlay window outside the React Native view tree. This
23
+ * isolates the webview from RN re-renders, navigation transitions, and
24
+ * other lifecycle events.
25
+ *
26
+ * Always render the `WebView` returned under
27
+ * `extension.reactNative.WebView`. When the native overlay is active it is a
28
+ * no-op component that renders nothing — the native overlay is created
29
+ * lazily and retained for the process lifetime, and subsequent extension
30
+ * factory invocations re-bind the JS bridge to the same native overlay (e.g.
31
+ * when the consumer recreates the client with a new `environmentId`).
32
+ *
33
+ * The native module was introduced mid-version, so an over-the-air JS update
34
+ * can land on an older native binary that predates it. When the module is not
35
+ * linked, this flag is transparently ignored and the returned `WebView`
36
+ * becomes the regular react-native-webview component, which must be mounted
37
+ * for the SDK to initialise — hence always render it.
38
+ *
39
+ * On the native overlay path there is no automatic load recovery. Any HTTP
40
+ * error, network failure, blocked navigation, SSL error, or process
41
+ * termination surfaces as `core.initialization.error` with
42
+ * `WebViewFailedToLoadError` — consumers should treat the SDK as
43
+ * un-initialised and react accordingly.
44
+ *
45
+ * On platforms other than iOS / Android (e.g. web), this flag is ignored.
46
+ * Defaults to false.
47
+ */
48
+ embeddedWebView?: boolean;
49
+ /**
50
+ * Customer-tunable budgets of the webview load engine (how long each
51
+ * load attempt may take and how long the SDK inside the webview may take
52
+ * to become ready). Applies to both webview paths. When a budget is
53
+ * exhausted on the final attempt, the SDK raises
54
+ * `WebViewFailedToLoadError`. See `WebViewLoadOptions` for the per-field
55
+ * documentation and defaults. Only tune this for pathological networks.
56
+ */
57
+ webviewLoad?: WebViewLoadOptions;
58
+ };
59
+ export type IReactNativeExtension = {
60
+ reactNative: {
61
+ WebView: FC<WebViewProps> | (() => null);
62
+ };
63
+ };
64
+ export declare const ReactNativeExtension: ({ webviewUrl, webviewDebuggingEnabled, appOrigin, embeddedWebView, webviewLoad, }?: ReactNativeExtensionProps) => Extension<IReactNativeExtension>;
@@ -0,0 +1 @@
1
+ export * from './ReactNativeExtension';
@@ -0,0 +1,19 @@
1
+ import { Core } from '@dynamic-labs/legacy-client';
2
+ export type LogNativeModuleAvailabilityArgs = {
3
+ core: Core;
4
+ /** The `embeddedWebView` flag the consumer requested. */
5
+ embeddedWebView: boolean;
6
+ /** Whether the EmbeddedWebView native module is linked in this binary. */
7
+ embeddedWebViewAvailable: boolean;
8
+ /** Whether the Keychain native module is linked in this binary. */
9
+ keychainAvailable: boolean;
10
+ };
11
+ /**
12
+ * Reports the running package version and which native modules are linked into
13
+ * the current binary. The embedded webview / keychain modules were introduced
14
+ * mid-version, so an over-the-air JS update can run ahead of the native binary;
15
+ * pairing the version with the availability matrix surfaces that gap (and lets
16
+ * `embeddedWebViewRequested && !embeddedWebViewAvailable` quantify the
17
+ * react-native-webview fallback rate).
18
+ */
19
+ export declare const logNativeModuleAvailability: ({ core, embeddedWebView, embeddedWebViewAvailable, keychainAvailable, }: LogNativeModuleAvailabilityArgs) => void;
@@ -0,0 +1 @@
1
+ export { setupKeychainHandler } from './setupKeychainHandler';
@@ -0,0 +1,2 @@
1
+ import { Core } from '@dynamic-labs/legacy-client';
2
+ export declare const setupKeychainHandler: (core: Core) => void;
@@ -0,0 +1 @@
1
+ export { setupPasskeyHandler } from './setupPasskeyHandler';
@@ -0,0 +1,2 @@
1
+ import { Core } from '@dynamic-labs/legacy-client';
2
+ export declare const setupPasskeyHandler: (core: Core) => void;
@@ -0,0 +1 @@
1
+ export * from './setupPlatformHandler';
@@ -0,0 +1,2 @@
1
+ import { Core } from '@dynamic-labs/legacy-client';
2
+ export declare const setupPlatformHandler: (core: Core) => void;
@@ -0,0 +1 @@
1
+ export { setupStorageHandler } from './setupStorageHandler';
@@ -0,0 +1,2 @@
1
+ import { Core } from '@dynamic-labs/legacy-client';
2
+ export declare const setupStorageHandler: (core: Core) => void;
@@ -0,0 +1 @@
1
+ export { setupTurnkeyPasskeyHandler } from './setupTurnkeyPasskeyHandler';
@@ -0,0 +1,2 @@
1
+ import { Core } from '@dynamic-labs/legacy-client';
2
+ export declare const setupTurnkeyPasskeyHandler: (core: Core) => void;
@@ -0,0 +1,13 @@
1
+ import { Core, WebViewLoadOptions } from '@dynamic-labs/legacy-client';
2
+ export type SetupEmbeddedWebViewArgs = {
3
+ webviewUrl: string;
4
+ core: Core;
5
+ webviewDebuggingEnabled?: boolean;
6
+ /**
7
+ * Customer-tunable budgets of the webview load engine. Forwarded
8
+ * verbatim to `createWebViewLoadController`, which owns the defaults.
9
+ * See `WebViewLoadOptions` for the per-field documentation.
10
+ */
11
+ webviewLoad?: WebViewLoadOptions;
12
+ };
13
+ export declare const setupEmbeddedWebView: ({ webviewUrl, core, webviewDebuggingEnabled, webviewLoad, }: SetupEmbeddedWebViewArgs) => (() => void);
@@ -0,0 +1 @@
1
+ export * from './EmbeddedWebView';
@@ -0,0 +1,37 @@
1
+ import { FC } from 'react';
2
+ import { Core, WebViewLoadOptions } from '@dynamic-labs/legacy-client';
3
+ export type WebViewProps = {
4
+ /**
5
+ * @deprecated No-op, accepted only for backwards compatibility. Webview
6
+ * load recovery is owned by the shared webview load controller (bounded
7
+ * retries with backoff) and is always on — it can no longer be disabled.
8
+ */
9
+ disableRecovery?: boolean;
10
+ /**
11
+ * @deprecated Configure `webviewLoad.sdkReadyTimeoutMs` on
12
+ * `ReactNativeExtension` instead. Still honored; an explicit value here
13
+ * overrides the extension setting.
14
+ */
15
+ recoveryTimeout?: number;
16
+ /**
17
+ * @deprecated Configure `webviewLoad.pageLoadTimeoutMs` on
18
+ * `ReactNativeExtension` instead. Still honored; an explicit value here
19
+ * overrides the extension setting.
20
+ */
21
+ loadingTimeout?: number;
22
+ };
23
+ type WebViewInternalProps = WebViewProps & {
24
+ webviewUrl: string;
25
+ core: Core;
26
+ webviewDebuggingEnabled?: boolean;
27
+ /**
28
+ * Customer-tunable budgets of the webview load engine, as configured on
29
+ * `ReactNativeExtension`. Forwarded to `createWebViewLoadController`;
30
+ * the deprecated `loadingTimeout` / `recoveryTimeout` JSX props override
31
+ * the two timeout fields when set explicitly.
32
+ */
33
+ webviewLoad?: WebViewLoadOptions;
34
+ };
35
+ export declare const WebView: FC<WebViewInternalProps>;
36
+ export declare const createWebView: (internalProps: WebViewInternalProps) => FC<WebViewProps>;
37
+ export {};
@@ -0,0 +1,26 @@
1
+ export declare const styles: {
2
+ container: {
3
+ backgroundColor: string;
4
+ bottom: number;
5
+ flex: number;
6
+ left: number;
7
+ position: "absolute";
8
+ right: number;
9
+ top: number;
10
+ width: "100%";
11
+ };
12
+ hide: {
13
+ elevation: number;
14
+ opacity: number;
15
+ zIndex: number;
16
+ };
17
+ show: {
18
+ elevation: number;
19
+ opacity: number;
20
+ zIndex: number;
21
+ };
22
+ webview: {
23
+ backgroundColor: string;
24
+ flex: number;
25
+ };
26
+ };
@@ -0,0 +1 @@
1
+ export * from './WebView';
@@ -0,0 +1 @@
1
+ export { useMessageTransportWebViewBridge } from './useMessageTransportWebViewBridge';
@@ -0,0 +1,6 @@
1
+ import { MutableRefObject } from 'react';
2
+ import { WebView as ReactNativeWebView, WebViewMessageEvent } from 'react-native-webview';
3
+ import { Core } from '@dynamic-labs/legacy-client';
4
+ export declare const useMessageTransportWebViewBridge: (core: Core, webViewRef: MutableRefObject<ReactNativeWebView | null>) => {
5
+ onMessageHandler: (event: WebViewMessageEvent) => void;
6
+ };
@@ -0,0 +1 @@
1
+ export { useWebViewVisibility } from './useWebViewVisibility';
@@ -0,0 +1,4 @@
1
+ import { Core } from '@dynamic-labs/legacy-client';
2
+ export declare const useWebViewVisibility: (core: Core) => {
3
+ visible: boolean;
4
+ };
@@ -0,0 +1 @@
1
+ export * from './shouldAllowNavigation';
@@ -0,0 +1,5 @@
1
+ export type NavigationRequest = {
2
+ url: string;
3
+ isTopFrame: boolean;
4
+ };
5
+ export declare const shouldAllowNavigation: (request: NavigationRequest, webViewUrl: URL) => boolean;
@@ -0,0 +1 @@
1
+ export { WebViewFailedToLoadError, type WebViewFailedToLoadErrorMeta, type WebViewFailedToLoadErrorPhase, type WebViewLoadAttemptFailure, } from '@dynamic-labs/legacy-client';
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { ReactNativeExtension, type IReactNativeExtension, } from './ReactNativeExtension';
2
+ export { WebViewFailedToLoadError } from './errors/WebViewFailedToLoadError';
@@ -0,0 +1,68 @@
1
+ export type EmbeddedWebViewSubscription = {
2
+ remove: () => void;
3
+ };
4
+ export type EmbeddedWebViewOnMessageEvent = {
5
+ message: string;
6
+ };
7
+ export type EmbeddedWebViewOnShouldStartLoadEvent = {
8
+ id: string;
9
+ url: string;
10
+ isTopFrame: boolean;
11
+ };
12
+ export type EmbeddedWebViewOnLoadErrorEvent = {
13
+ url: string;
14
+ code: number;
15
+ domain: string;
16
+ description: string;
17
+ isProvisional: boolean;
18
+ };
19
+ /**
20
+ * Fired when the native webview starts a provisional navigation — the
21
+ * request has been issued but no response bytes have arrived yet.
22
+ * Maps to `WKNavigationDelegate.didStartProvisionalNavigation` on iOS and
23
+ * `WebViewClient.onPageStarted` on Android.
24
+ */
25
+ export type EmbeddedWebViewOnLoadStartEvent = {
26
+ url: string;
27
+ };
28
+ /**
29
+ * Fired when the response has committed and the native webview has begun
30
+ * rendering. Maps to `WKNavigationDelegate.didCommit` on iOS and
31
+ * `WebViewClient.onPageCommitVisible` on Android.
32
+ */
33
+ export type EmbeddedWebViewOnLoadEvent = {
34
+ url: string;
35
+ };
36
+ /**
37
+ * Fired when the native webview finishes loading the page. Maps to
38
+ * `WKNavigationDelegate.didFinish` on iOS and `WebViewClient.onPageFinished`
39
+ * on Android.
40
+ */
41
+ export type EmbeddedWebViewOnLoadEndEvent = {
42
+ url: string;
43
+ };
44
+ export type EmbeddedWebViewEventName = 'onMessage' | 'onShouldStartLoad' | 'onLoadError' | 'onLoadStart' | 'onLoad' | 'onLoadEnd';
45
+ export type EmbeddedWebViewNativeModule = {
46
+ setUrl: (url: string) => Promise<void>;
47
+ setVisible: (visible: boolean) => Promise<void>;
48
+ setDebuggingEnabled: (enabled: boolean) => Promise<void>;
49
+ destroy: () => Promise<void>;
50
+ postMessage: (message: string) => Promise<void>;
51
+ respondToShouldStartLoad: (id: string, allow: boolean) => Promise<void>;
52
+ addListener: <T extends EmbeddedWebViewOnMessageEvent | EmbeddedWebViewOnShouldStartLoadEvent | EmbeddedWebViewOnLoadErrorEvent | EmbeddedWebViewOnLoadStartEvent | EmbeddedWebViewOnLoadEvent | EmbeddedWebViewOnLoadEndEvent>(eventName: EmbeddedWebViewEventName, listener: (event: T) => void) => EmbeddedWebViewSubscription;
53
+ };
54
+ /**
55
+ * Reports whether the EmbeddedWebView native module is linked into the
56
+ * currently running native binary.
57
+ *
58
+ * The embedded webview was introduced mid-version, so an over-the-air JS
59
+ * update can land on an older binary that predates the native module. Callers
60
+ * use this to decide between the native overlay path and the
61
+ * react-native-webview fallback before wiring any side effects.
62
+ *
63
+ * `requireOptionalNativeModule` returns `null` (instead of throwing) when the
64
+ * module is absent. Any unexpected throw is treated as "unavailable" so a
65
+ * runtime quirk can never break the calling flow.
66
+ */
67
+ export declare const isEmbeddedWebViewAvailable: () => boolean;
68
+ export declare const getEmbeddedWebView: () => EmbeddedWebViewNativeModule;
@@ -0,0 +1,23 @@
1
+ type KeychainNativeModule = {
2
+ isAvailable: () => Promise<boolean>;
3
+ hasKey: (key: string) => Promise<boolean>;
4
+ generateKeyPair: (key: string) => Promise<{
5
+ publicKey: string;
6
+ }>;
7
+ getPublicKey: (key: string) => Promise<{
8
+ publicKey: string;
9
+ } | null>;
10
+ sign: (key: string, payload: string) => Promise<{
11
+ signature: string;
12
+ }>;
13
+ deleteKey: (key: string) => Promise<void>;
14
+ };
15
+ /**
16
+ * Reports whether the Keychain native module is linked into the currently
17
+ * running native binary. Mirrors `isEmbeddedWebViewAvailable`: an over-the-air
18
+ * JS update can run on an older binary that predates the module, so any
19
+ * unexpected throw is treated as "unavailable".
20
+ */
21
+ export declare const isKeychainAvailable: () => boolean;
22
+ export declare const getKeychain: () => KeychainNativeModule;
23
+ export {};
@@ -0,0 +1 @@
1
+ export { getKeychain } from './Keychain';
@@ -0,0 +1,2 @@
1
+ import { Logger } from '@dynamic-labs/logger';
2
+ export declare const logger: Logger;
@@ -0,0 +1,47 @@
1
+ // VENDORED from @dynamic-labs-sdk/client (src/turboModules/NativeDynamicWebView.ts).
2
+ // The OLD SDK pulls @dynamic-labs-sdk/client in transitively, and iOS React
3
+ // Native codegen only generates TurboModule specs for DIRECT app dependencies.
4
+ // react-native-extension is a direct dependency of old-SDK apps, so carrying the
5
+ // codegen spec here makes the consuming app generate DynamicClientSpec/*.h for
6
+ // the transitively-linked native module. Keep byte-identical to the source spec
7
+ // in @dynamic-labs-sdk/client — update there and re-copy, do not edit here.
8
+ //
9
+ // The `interface`, `default export`, and the `react-native` import are hard
10
+ // requirements of the codegen parser and intentionally deviate from the
11
+ // project's conventions. Codegen discovers specs by the `Native*` filename
12
+ // prefix, so this file cannot be renamed to `.native.ts`.
13
+
14
+ import { type TurboModule, TurboModuleRegistry } from 'react-native';
15
+ import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
16
+
17
+ export interface Spec extends TurboModule {
18
+ addListener(eventName: string): void;
19
+ close(instanceId: string): void;
20
+ /**
21
+ * Creates a WKWebView for the given instanceId and begins loading `url`.
22
+ *
23
+ * Resolves on `didCommit` — i.e. the first byte of a 2xx/3xx HTTP
24
+ * response has been received and content parsing has started. Page-ready
25
+ * (e.g. the hosted iframe's `iframe-ready-*` handshake) is a separate
26
+ * concern and must be observed by the caller via the message bus; this
27
+ * Promise does not wait for it.
28
+ *
29
+ * Rejects with a `code` of `webview_<reason>` where `<reason>` is one of:
30
+ * - `invalid_url` — URL string was not parseable
31
+ * - `no_host_view` — no foreground window to attach the WebView
32
+ * - `http_error` — response status was >= 400 (userInfo contains `DynamicWebViewStatusCode`)
33
+ * - `navigation_failed` — DNS, TLS, connection failure, or post-commit abort
34
+ * - `cancelled` — `close(instanceId)` was called while this open was pending
35
+ * - `instance_busy` — `open` was called for an instanceId that already has an active WebView
36
+ * - `content_process_terminated` — the WKWebView WebContent process died during load
37
+ * - `unsupported` — the device's Android System WebView is too old to support the secure bridge (Android only)
38
+ *
39
+ * rejection codes into typed `WebViewLoadFailedError` instances.
40
+ */
41
+ open(instanceId: string, url: string): Promise<void>;
42
+ removeListeners(count: number): void;
43
+ sendMessage(instanceId: string, data: UnsafeObject): void;
44
+ }
45
+
46
+ // eslint-disable-next-line import/no-default-export
47
+ export default TurboModuleRegistry.get<Spec>('DynamicClientWebView');
@@ -0,0 +1,22 @@
1
+ // VENDORED from @dynamic-labs-sdk/client (src/turboModules/NativeKeychain.ts).
2
+ // See NativeDynamicWebView.ts in this directory for why the spec is carried here.
3
+ // Keep byte-identical to the source spec in @dynamic-labs-sdk/client.
4
+ //
5
+ // The `interface`, `default export`, and `react-native` import are hard
6
+ // requirements of the codegen parser and intentionally deviate from the
7
+ // project's conventions. Codegen discovers specs by the `Native*` filename
8
+ // prefix, so this file cannot be renamed to `.native.ts`.
9
+
10
+ import { type TurboModule, TurboModuleRegistry } from 'react-native';
11
+
12
+ export interface Spec extends TurboModule {
13
+ deleteKey(key: string): Promise<void>;
14
+ generateKeyPair(key: string): Promise<{ publicKey: string }>;
15
+ getPublicKey(key: string): Promise<{ publicKey: string } | null>;
16
+ hasKey(key: string): Promise<boolean>;
17
+ isAvailable(): Promise<boolean>;
18
+ sign(key: string, payload: string): Promise<{ signature: string }>;
19
+ }
20
+
21
+ // eslint-disable-next-line import/no-default-export
22
+ export default TurboModuleRegistry.getEnforcing<Spec>('DynamicClientKeychain');