@dynamic-labs-sdk/client 1.7.0 → 1.8.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.
Files changed (119) hide show
  1. package/android/build.gradle +231 -0
  2. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  3. package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  4. package/android/gradle.properties +8 -0
  5. package/android/gradlew +251 -0
  6. package/android/gradlew.bat +94 -0
  7. package/android/settings.gradle +30 -0
  8. package/android/src/main/java/xyz/dynamic/client/DynamicClientPackage.kt +52 -0
  9. package/android/src/main/java/xyz/dynamic/client/keychain/KeyStoreKeyManager.kt +147 -0
  10. package/android/src/main/java/xyz/dynamic/client/keychain/KeychainModule.kt +85 -0
  11. package/android/src/main/java/xyz/dynamic/client/manifest/ReactNativeManifestModule.kt +25 -0
  12. package/android/src/main/java/xyz/dynamic/client/webview/DynamicWebViewClient.kt +83 -0
  13. package/android/src/main/java/xyz/dynamic/client/webview/DynamicWebViewHost.kt +518 -0
  14. package/android/src/main/java/xyz/dynamic/client/webview/DynamicWebViewModule.kt +147 -0
  15. package/android/src/test/java/xyz/dynamic/client/keychain/KeyStoreKeyManagerTest.kt +288 -0
  16. package/android/src/test/java/xyz/dynamic/client/webview/DynamicWebViewClientTest.kt +196 -0
  17. package/android/src/test/java/xyz/dynamic/client/webview/DynamicWebViewHostOpenTest.kt +347 -0
  18. package/android/src/test/java/xyz/dynamic/client/webview/DynamicWebViewHostTest.kt +171 -0
  19. package/android/src/test/java/xyz/dynamic/client/webview/DynamicWebViewModuleTest.kt +191 -0
  20. package/dist/{InvalidParamError-Crwntjl7.native.esm.js → InvalidParamError-BKnC9rcJ.esm.js} +441 -10
  21. package/dist/InvalidParamError-BKnC9rcJ.esm.js.map +1 -0
  22. package/dist/{InvalidParamError-fQLJaGBW.esm.js → InvalidParamError-Btv8VGSa.native.esm.js} +3 -3
  23. package/dist/InvalidParamError-Btv8VGSa.native.esm.js.map +1 -0
  24. package/dist/{InvalidParamError-CTssOe86.cjs → InvalidParamError-DGBih-LJ.cjs} +550 -4
  25. package/dist/InvalidParamError-DGBih-LJ.cjs.map +1 -0
  26. package/dist/{NotWaasWalletAccountError-DF_S7gqo.esm.js → NotWaasWalletAccountError-CHr72wTH.esm.js} +3 -3
  27. package/dist/{NotWaasWalletAccountError-DF_S7gqo.esm.js.map → NotWaasWalletAccountError-CHr72wTH.esm.js.map} +1 -1
  28. package/dist/{NotWaasWalletAccountError-BJLGGYmU.native.esm.js → NotWaasWalletAccountError-CRmyVoB3.native.esm.js} +3 -3
  29. package/dist/{NotWaasWalletAccountError-BJLGGYmU.native.esm.js.map → NotWaasWalletAccountError-CRmyVoB3.native.esm.js.map} +1 -1
  30. package/dist/{NotWaasWalletAccountError-2RaDipZu.cjs → NotWaasWalletAccountError-i1FozGep.cjs} +3 -3
  31. package/dist/{NotWaasWalletAccountError-2RaDipZu.cjs.map → NotWaasWalletAccountError-i1FozGep.cjs.map} +1 -1
  32. package/dist/core.cjs +23 -23
  33. package/dist/core.cjs.map +1 -1
  34. package/dist/core.esm.js +5 -5
  35. package/dist/core.native.esm.js +7 -7
  36. package/dist/core.native.esm.js.map +1 -1
  37. package/dist/errors/WebViewLoadFailedError.d.ts +1 -1
  38. package/dist/errors/WebViewLoadFailedError.d.ts.map +1 -1
  39. package/dist/exports/index.d.ts +2 -0
  40. package/dist/exports/index.d.ts.map +1 -1
  41. package/dist/{getNetworkProviderFromNetworkId-C1p9Rrg3.cjs → getNetworkProviderFromNetworkId-BdgI7g5U.cjs} +11 -317
  42. package/dist/getNetworkProviderFromNetworkId-BdgI7g5U.cjs.map +1 -0
  43. package/dist/{getNetworkProviderFromNetworkId-BCSmILlH.native.esm.js → getNetworkProviderFromNetworkId-Bm41knUq.native.esm.js} +6 -6
  44. package/dist/getNetworkProviderFromNetworkId-Bm41knUq.native.esm.js.map +1 -0
  45. package/dist/{getNetworkProviderFromNetworkId-BWhaD23J.esm.js → getNetworkProviderFromNetworkId-CRuh5pgc.esm.js} +4 -242
  46. package/dist/getNetworkProviderFromNetworkId-CRuh5pgc.esm.js.map +1 -0
  47. package/dist/{getSignedSessionId-CxxYNC_8.cjs → getSignedSessionId-Cwmt4BkY.cjs} +3 -3
  48. package/dist/{getSignedSessionId-CxxYNC_8.cjs.map → getSignedSessionId-Cwmt4BkY.cjs.map} +1 -1
  49. package/dist/{getSignedSessionId-c7dS4PQ9.esm.js → getSignedSessionId-D2w_IRdt.esm.js} +3 -3
  50. package/dist/{getSignedSessionId-c7dS4PQ9.esm.js.map → getSignedSessionId-D2w_IRdt.esm.js.map} +1 -1
  51. package/dist/{getSignedSessionId-DPOXdh6y.native.esm.js → getSignedSessionId-S6CBWkOn.native.esm.js} +3 -3
  52. package/dist/{getSignedSessionId-DPOXdh6y.native.esm.js.map → getSignedSessionId-S6CBWkOn.native.esm.js.map} +1 -1
  53. package/dist/getVerifiedCredentialForWalletAccount-CDuP1kaI.cjs +347 -0
  54. package/dist/getVerifiedCredentialForWalletAccount-CDuP1kaI.cjs.map +1 -0
  55. package/dist/{getVerifiedCredentialForWalletAccount-Cahp763h.esm.js → getVerifiedCredentialForWalletAccount-D33r7Drd.native.esm.js} +2 -2
  56. package/dist/{getVerifiedCredentialForWalletAccount-DuNbORNW.native.esm.js.map → getVerifiedCredentialForWalletAccount-D33r7Drd.native.esm.js.map} +1 -1
  57. package/dist/getVerifiedCredentialForWalletAccount-QwfkKHfr.esm.js +269 -0
  58. package/dist/getVerifiedCredentialForWalletAccount-QwfkKHfr.esm.js.map +1 -0
  59. package/dist/index.cjs +67 -67
  60. package/dist/index.cjs.map +1 -1
  61. package/dist/index.esm.js +5 -5
  62. package/dist/index.esm.js.map +1 -1
  63. package/dist/index.native.esm.js +5 -5
  64. package/dist/index.native.esm.js.map +1 -1
  65. package/dist/isMfaRequiredForAction-5p3i98-Z.esm.js +318 -0
  66. package/dist/isMfaRequiredForAction-5p3i98-Z.esm.js.map +1 -0
  67. package/dist/{isMfaRequiredForAction-D8G5PBAd.native.esm.js → isMfaRequiredForAction-cmElIVof.native.esm.js} +2 -2
  68. package/dist/{isMfaRequiredForAction-D8G5PBAd.native.esm.js.map → isMfaRequiredForAction-cmElIVof.native.esm.js.map} +1 -1
  69. package/dist/isMfaRequiredForAction-z74isCQ7.cjs +405 -0
  70. package/dist/isMfaRequiredForAction-z74isCQ7.cjs.map +1 -0
  71. package/dist/modules/waas/createWaasClient/createWaasClient.d.ts.map +1 -1
  72. package/dist/modules/waas/createWaasClient/translateNativeOpenError.d.ts.map +1 -1
  73. package/dist/modules/wallets/walletProvider/events/onWalletProviderEvent/onWalletProviderEvent.d.ts +1 -2
  74. package/dist/modules/wallets/walletProvider/events/onWalletProviderEvent/onWalletProviderEvent.d.ts.map +1 -1
  75. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  76. package/dist/waas.cjs +9 -9
  77. package/dist/waas.cjs.map +1 -1
  78. package/dist/waas.esm.js +3 -3
  79. package/dist/waas.native.esm.js +3 -3
  80. package/dist/waasCore.cjs +8 -5
  81. package/dist/waasCore.cjs.map +1 -1
  82. package/dist/waasCore.esm.js +8 -4
  83. package/dist/waasCore.esm.js.map +1 -1
  84. package/dist/waasCore.native.esm.js +9 -8
  85. package/dist/waasCore.native.esm.js.map +1 -1
  86. package/dynamic-labs-sdk-client.podspec +27 -0
  87. package/ios/DynamicClientKeychain.h +4 -0
  88. package/ios/DynamicClientKeychain.mm +101 -0
  89. package/ios/DynamicClientManifest.h +4 -0
  90. package/ios/DynamicClientManifest.mm +45 -0
  91. package/ios/DynamicClientWebView.h +5 -0
  92. package/ios/DynamicClientWebView.mm +143 -0
  93. package/ios/DynamicWebViewImpl.swift +603 -0
  94. package/ios/LiveSecKeyAPI.swift +86 -0
  95. package/ios/ReactNativeManifestImpl.swift +20 -0
  96. package/ios/SecKeyAPI.swift +57 -0
  97. package/ios/SecureEnclaveKeyManager.swift +191 -0
  98. package/package.json +14 -5
  99. package/react-native.config.cjs +14 -0
  100. package/src/turboModules/NativeDynamicWebView.native.spec.ts +61 -0
  101. package/src/turboModules/NativeDynamicWebView.ts +40 -0
  102. package/src/turboModules/NativeKeychain.native.spec.ts +47 -0
  103. package/src/turboModules/NativeKeychain.ts +19 -0
  104. package/src/turboModules/NativeReactNativeManifest.native.spec.ts +55 -0
  105. package/src/turboModules/NativeReactNativeManifest.ts +28 -0
  106. package/dist/InvalidParamError-CTssOe86.cjs.map +0 -1
  107. package/dist/InvalidParamError-Crwntjl7.native.esm.js.map +0 -1
  108. package/dist/InvalidParamError-fQLJaGBW.esm.js.map +0 -1
  109. package/dist/getNetworkProviderFromNetworkId-BCSmILlH.native.esm.js.map +0 -1
  110. package/dist/getNetworkProviderFromNetworkId-BWhaD23J.esm.js.map +0 -1
  111. package/dist/getNetworkProviderFromNetworkId-C1p9Rrg3.cjs.map +0 -1
  112. package/dist/getVerifiedCredentialForWalletAccount-Cahp763h.esm.js.map +0 -1
  113. package/dist/getVerifiedCredentialForWalletAccount-Di8dM5Wx.cjs +0 -887
  114. package/dist/getVerifiedCredentialForWalletAccount-Di8dM5Wx.cjs.map +0 -1
  115. package/dist/getVerifiedCredentialForWalletAccount-DuNbORNW.native.esm.js +0 -701
  116. package/dist/isMfaRequiredForAction-BjRvPrU6.esm.js +0 -79
  117. package/dist/isMfaRequiredForAction-BjRvPrU6.esm.js.map +0 -1
  118. package/dist/isMfaRequiredForAction-hlhj0qAC.cjs +0 -96
  119. package/dist/isMfaRequiredForAction-hlhj0qAC.cjs.map +0 -1
@@ -0,0 +1,143 @@
1
+ #import "DynamicClientWebView.h"
2
+ #import <React/RCTBridgeModule.h>
3
+ #import <React/RCTEventEmitter.h>
4
+ #import <DynamicClientSpec/DynamicClientSpec.h>
5
+ #if __has_include(<dynamic_labs_sdk_client/dynamic_labs_sdk_client-Swift.h>)
6
+ #import <dynamic_labs_sdk_client/dynamic_labs_sdk_client-Swift.h>
7
+ #else
8
+ #import "dynamic_labs_sdk_client-Swift.h"
9
+ #endif
10
+
11
+ static NSString *const kMessageEventName = @"dynamicBridgeMessage";
12
+
13
+ @interface DynamicClientWebView () <NativeDynamicWebViewSpec, DynamicWebViewImplDelegate> {
14
+ DynamicWebViewImpl *_impl;
15
+ BOOL _hasListeners;
16
+ // Messages that arrived before JS attached its listener (e.g. the
17
+ // iframe-ready handshake posted between `open` resolving and `onMessage`
18
+ // subscribing). Flushed in order on startObserving so the handshake is not
19
+ // lost. Accessed from two queues — the WKScriptMessageHandler callback runs
20
+ // on the main thread while startObserving/stopObserving run on the
21
+ // RCTEventEmitter method queue — so all access is serialized with
22
+ // @synchronized(self).
23
+ NSMutableArray<NSDictionary *> *_bufferedEvents;
24
+ }
25
+ @end
26
+
27
+ @implementation DynamicClientWebView
28
+
29
+ RCT_EXPORT_MODULE()
30
+
31
+ - (instancetype)init {
32
+ self = [super init];
33
+ if (self) {
34
+ _impl = [[DynamicWebViewImpl alloc] init];
35
+ _impl.delegate = self;
36
+ _bufferedEvents = [NSMutableArray array];
37
+ }
38
+ return self;
39
+ }
40
+
41
+ #pragma mark - RCTEventEmitter
42
+
43
+ - (NSArray<NSString *> *)supportedEvents {
44
+ return @[ kMessageEventName ];
45
+ }
46
+
47
+ - (void)startObserving {
48
+ // Flush messages buffered before the first listener attached, in order, so an
49
+ // early handshake message is delivered rather than dropped. Snapshot under
50
+ // the lock; send outside it so sendEventWithName: never runs while holding it.
51
+ NSArray<NSDictionary *> *pending;
52
+ @synchronized(self) {
53
+ _hasListeners = YES;
54
+ pending = [_bufferedEvents copy];
55
+ [_bufferedEvents removeAllObjects];
56
+ }
57
+ for (NSDictionary *event in pending) {
58
+ [self sendEventWithName:kMessageEventName body:event];
59
+ }
60
+ }
61
+
62
+ - (void)stopObserving {
63
+ @synchronized(self) {
64
+ _hasListeners = NO;
65
+ }
66
+ }
67
+
68
+ #pragma mark - NativeDynamicWebViewSpec
69
+
70
+ - (void)open:(NSString *)instanceId
71
+ url:(NSString *)url
72
+ resolve:(RCTPromiseResolveBlock)resolve
73
+ reject:(RCTPromiseRejectBlock)reject {
74
+ [_impl openWithInstanceId:instanceId
75
+ url:url
76
+ completion:^(NSError * _Nullable error) {
77
+ if (error) {
78
+ // The Swift impl stores a discriminator string under the
79
+ // `DynamicWebViewReason` userInfo key. Surface it as the RCT reject
80
+ // code so the JS wrapper can translate to a typed
81
+ // `WebViewLoadFailedError` without parsing messages.
82
+ NSString *reason = error.userInfo[@"DynamicWebViewReason"];
83
+ NSString *rejectCode = reason
84
+ ? [NSString stringWithFormat:@"webview_%@", reason]
85
+ : @"webview_load_failed_error";
86
+ reject(rejectCode, error.localizedDescription, error);
87
+ return;
88
+ }
89
+ resolve([NSNull null]);
90
+ }];
91
+ }
92
+
93
+ - (void)sendMessage:(NSString *)instanceId data:(NSDictionary *)data {
94
+ [_impl sendMessageWithInstanceId:instanceId data:data];
95
+ }
96
+
97
+ - (void)close:(NSString *)instanceId {
98
+ [_impl closeWithInstanceId:instanceId];
99
+ }
100
+
101
+ - (void)addListener:(NSString *)eventName {
102
+ // Delegate to RCTEventEmitter so its internal listener counter increments
103
+ // and `startObserving` fires on the 0 -> 1 transition. Declaring this method
104
+ // in the TurboModule spec is required for codegen compatibility; forgetting
105
+ // to chain to super silently breaks event delivery (hasListeners stays NO).
106
+ [super addListener:eventName];
107
+ }
108
+
109
+ - (void)removeListeners:(double)count {
110
+ [super removeListeners:count];
111
+ }
112
+
113
+ #pragma mark - DynamicWebViewImplDelegate
114
+
115
+ - (void)didReceiveMessageForInstanceId:(NSString *)instanceId
116
+ data:(id)data {
117
+ NSDictionary *event =
118
+ @{ @"instanceId": instanceId, @"data": data ?: [NSNull null] };
119
+ @synchronized(self) {
120
+ if (!_hasListeners) {
121
+ // Buffer until a listener attaches; otherwise an early message (the
122
+ // iframe-ready handshake) would be silently dropped and the ceremony
123
+ // would stall until the WaaS handshake timeout.
124
+ [_bufferedEvents addObject:event];
125
+ return;
126
+ }
127
+ }
128
+ [self sendEventWithName:kMessageEventName body:event];
129
+ }
130
+
131
+ #pragma mark - TurboModule
132
+
133
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
134
+ (const facebook::react::ObjCTurboModule::InitParams &)params {
135
+ return std::make_shared<facebook::react::NativeDynamicWebViewSpecJSI>(
136
+ params);
137
+ }
138
+
139
+ + (BOOL)requiresMainQueueSetup {
140
+ return NO;
141
+ }
142
+
143
+ @end